package com.spring.applicationcontext_demo;

import com.spring.demo01.MyService;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * 全局上下文工具类使用
 * 依赖xml: spring-applicationcontext.xml
 */
public class Apps {
	public static void main(String[] args) {
		ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring.xml");
		ApplicationContextUtil util = (ApplicationContextUtil) context.getBean("applicationContextUtil");
		MyService myservice = (MyService) util.getBean("myservice");
		String item = myservice.getItem();
		System.out.println(item);
	}
}
